<?php
// lib/Jobeet.class.php
class Jobeet
{
  static public function slugify($text)
  {
    // ADDED: Deal with accents vvvvvvvvvvvv
    $text = preg_replace('/á|Á/', 'a', $text);
    $text = preg_replace('/é|É/', 'e', $text);
    $text = preg_replace('/ê|Ê/', 'e', $text);
    $text = preg_replace('/è|È/', 'e', $text);
    $text = preg_replace('/í|Í/', 'i', $text);
    $text = preg_replace('/ó|Ó/', 'o', $text);
    $text = preg_replace('/ú|Ú/', 'u', $text);

    $text = preg_replace('/Ñ|ñ/', 'nn', $text);
    // End of Deal  with accents 

    // replace all non letters or digits by -
    $text = preg_replace('/\W+/', '-', $text);

    // trim and lowercase
    $text = strtolower(trim($text, '-'));
     
    return $text;
  }
}
